package com.bw.lib_image
import android.content.Context
import android.util.Log
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory
import com.bumptech.glide.load.engine.cache.LruResourceCache
import com.bumptech.glide.module.AppGlideModule

/**
 * @author ykj
 * @date 2025-10-15 20:58
 * @description
 * 根据设备动态调整磁盘和内存的大小
 */



/**
 * 根据设备动态调整磁盘和内存大小
 */
@GlideModule
class DynamicGlideModule:AppGlideModule(){
    override fun applyOptions(context: Context, builder: GlideBuilder) {
//        super.applyOptions(context, builder)
        //内存大小
//        val calculateMemoryCacheSize = GlideCacheManager.calculateMemoryCacheSize(context)
//        Log.d("DynamicGlideModule", "calculateMemoryCacheSize: $calculateMemoryCacheSize")
//        builder.setMemoryCache(LruResourceCache(calculateMemoryCacheSize))
//        //磁盘大小
//        val calculateDiskCacheSize = GlideCacheManager.calculateDiskCacheSize(context)
//        Log.d("DynamicGlideModule", "calculateDiskCacheSize: $calculateDiskCacheSize")
//        builder.setDiskCache(InternalCacheDiskCacheFactory(context,"club_glide_disk",calculateDiskCacheSize))

    }
}